Skip to content

feat: add LLMAnalytics.pop_span/1 function#139

Merged
marandaneto merged 1 commit into
PostHog:mainfrom
martosaur:am-pop-span
Jun 16, 2026
Merged

feat: add LLMAnalytics.pop_span/1 function#139
marandaneto merged 1 commit into
PostHog:mainfrom
martosaur:am-pop-span

Conversation

@martosaur

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Currently LLMAnalytics span machinery supports the case when we spawn a new process and want all spans captured in it to be children of a parent process' span. But in some cases we want spawned process to continue a span that was started in the parent process. For these cases we need an LLMAnalytics.pop_span/1 function. This PR adds it.

💚 How did you test it?

unit tests + my own project

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

@martosaur martosaur requested a review from a team as a code owner June 16, 2026 00:15
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Comments Outside Diff (1)

  1. test/posthog/llm_analytics_test.exs, line 514-547 (link)

    P2 Prefer parameterised tests

    The first test ("pops current span from the backlog") and the last test ("custom PostHog instance") exercise the same scenario — starting a span and verifying pop_span returns it — just against different instances (PostHog vs MyPostHog). Per the team's convention these should be collapsed into a single parameterised test that iterates over both instances, which keeps the intent OnceAndOnlyOnce and makes future instance additions trivial.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: test/posthog/llm_analytics_test.exs
    Line: 514-547
    
    Comment:
    **Prefer parameterised tests**
    
    The first test ("pops current span from the backlog") and the last test ("custom PostHog instance") exercise the same scenario — starting a span and verifying `pop_span` returns it — just against different instances (`PostHog` vs `MyPostHog`). Per the team's convention these should be collapsed into a single parameterised test that iterates over both instances, which keeps the intent `OnceAndOnlyOnce` and makes future instance additions trivial.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
test/posthog/llm_analytics_test.exs:514-547
**Prefer parameterised tests**

The first test ("pops current span from the backlog") and the last test ("custom PostHog instance") exercise the same scenario — starting a span and verifying `pop_span` returns it — just against different instances (`PostHog` vs `MyPostHog`). Per the team's convention these should be collapsed into a single parameterised test that iterates over both instances, which keeps the intent `OnceAndOnlyOnce` and makes future instance additions trivial.

Reviews (1): Last reviewed commit: "feat: add LLMAnalytics.pop_span/1 functi..." | Re-trigger Greptile

@marandaneto marandaneto requested a review from a team June 16, 2026 05:41
@marandaneto

Copy link
Copy Markdown
Member

@martosaur update the public api snapshot pls https://github.com/PostHog/posthog-elixir/actions/runs/27585122912/job/81588456489?pr=139
cc @PostHog/team-ai-observability, I believe this would make sense across all SDKs with AIO, right?

@martosaur

Copy link
Copy Markdown
Contributor Author

@marandaneto done, updated the snapshot 🫡

@marandaneto marandaneto merged commit e086cb7 into PostHog:main Jun 16, 2026
28 checks passed
@martosaur martosaur deleted the am-pop-span branch June 16, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants